package VWorldGameStudio;

import lombok.Delegate;
import lombok.Getter;
import lombok.Setter;

import java.awt.Image;
import java.awt.Toolkit;
import java.util.ArrayList;

/**
 * 攻击动画
 * 
 * @param
 */
public class FCAnimation extends Sprite{
	// id，名字
	@Setter
	@Getter
	private String id;
	// 类型
	@Setter
	@Getter
	private String type = "static";

	///1是人类武器， 2是坦克 3是怪物
	@Setter
	@Getter
	public int animationForWho = 1;
	/**
	 * TODO 开火动画，枪口动画，或者是启动动画，比如逃跑动画,原地动画都在这里
	 */

	@Getter
	private ArrayList<String> firePngUrl = new ArrayList<>(0);//所有动画都最大10张图片
	@Getter
	private ArrayList<Image> firePng = new ArrayList<>(0);
	@Setter
	@Getter
	private int fireMusicId;
	public int firePngSizeW;
	public int firePngSizeH;
	public int firePngCenterOffsetX;
	public int firePngCenterOffsetY;
	@Getter
	public int fireFrameTime = 300;//300毫秒，表示这个动画播完300毫秒或者停住300毫秒
	//TODO 飞行动画，可以是一张图或者一连串动画图
	@Getter
	private ArrayList<String> flyingPngUrl = new ArrayList<>(0);
	@Getter
	private ArrayList<Image> flyingPng = new ArrayList<>(0);
	@Setter
	@Getter
	private int flyMusicId;
	public int flyingPngSizeW;
	public int flyingPngSizeH;
	public int flyingPngCenterOffsetX;
	public int flyingPngCenterOffsetY;

	//飞行动画2,可能有转折的动画
	@Getter
	@Deprecated
	private ArrayList<String> flyingPngUrl2 = new ArrayList<>(0);
	@Getter
	@Deprecated
	private ArrayList<Image> flyingPng2 = new ArrayList<>(0);
	@Setter
	@Getter
	@Deprecated
	private int flyMusicId2;
	@Deprecated
	public int flyingPngSizeW2;
	@Deprecated
	public int flyingPngSizeH2;
	@Deprecated
	public int flyingPngCenterOffsetX2;
	@Deprecated
	public int flyingPngCenterOffsetY2;

	//TODO 最后结尾的爆炸动画，反正是结束飞行后到达的动画,有就播放，没就不播
	@Getter
	private ArrayList<String> boomPngUrl = new ArrayList<>(0);
	@Getter
	private ArrayList<Image> boomPng = new ArrayList<>(0);
	@Setter
	@Getter
	private int boomMusicId;
	public int boomPngSizeW;
	public int boomPngSizeH;
	public int boomPngCenterOffsetX;
	public int boomPngCenterOffsetY;
	@Getter
	public int boomFrameTime = 500;

	@Getter
	@Setter
	public double boomPngScales = 1;//爆炸放大多少倍


	public void initAllImages(){
		for(String url: firePngUrl){
			firePng.add(Toolkit.getDefaultToolkit().getImage(url));
		}
		for(String url: flyingPngUrl){
			flyingPng.add(Toolkit.getDefaultToolkit().getImage(url));
		}
		for(String url: flyingPngUrl2){
			flyingPng2.add(Toolkit.getDefaultToolkit().getImage(url));
		}
		for(String url: boomPngUrl){
			boomPng.add(Toolkit.getDefaultToolkit().getImage(url));
		}
		System.out.println("boomPngScales:"+boomPngScales+" boomPng "+boomPng.size()+" flyingPng:"+flyingPng.size()+" firePng:"+firePng.size());
	}

	public String getID() {
		return id;
	}

	public String getType() {
		return type;
	}

	public String getFireAniForWrite() {
		StringBuilder stringBuilder = new StringBuilder();
		if(firePngUrl.size() > 0) {
			stringBuilder.append(firePngUrl.get(0));
		}
		if(firePngUrl.size() > 1) {
			for (int i = 1; i < firePngUrl.size(); i++) {
				stringBuilder.append("," + firePngUrl.get(i));
			}
		}
		return fireFrameTime+","+fireMusicId+","+firePngSizeW+","+firePngSizeH+","+firePngCenterOffsetX+","+firePngCenterOffsetY+","
				+firePngUrl.size()+","+stringBuilder.toString();
	}

	public String getFlyAniForWrite() {
		StringBuilder stringBuilder = new StringBuilder();
		if(flyingPngUrl.size() > 0) {
			stringBuilder.append(flyingPngUrl.get(0));
		}
		if(flyingPngUrl.size() > 1) {
			for (int i = 1; i < flyingPngUrl.size(); i++) {
				stringBuilder.append("," + flyingPngUrl.get(i));
			}
		}
		return 0+","+flyMusicId+","+flyingPngSizeW+","+flyingPngSizeH+","+flyingPngCenterOffsetX+","+flyingPngCenterOffsetY+","
				+flyingPngUrl.size()+","+stringBuilder.toString();
	}

	public String getFlyAniForWrite2() {
		StringBuilder stringBuilder = new StringBuilder();
		if(flyingPngUrl2.size() > 0) {
			stringBuilder.append(flyingPngUrl2.get(0));
		}
		if(flyingPngUrl2.size() > 1) {
			for (int i = 1; i < flyingPngUrl2.size(); i++) {
				stringBuilder.append("," + flyingPngUrl2.get(i));
			}
		}
		return 0+","+flyMusicId2+","+flyingPngSizeW2+","+flyingPngSizeH2+","+flyingPngCenterOffsetX2+","+flyingPngCenterOffsetY2+","
				+flyingPngUrl2.size()+","+stringBuilder.toString();
	}

	public String getBoomAniForWrite() {
		StringBuilder stringBuilder = new StringBuilder();
		if(boomPngUrl.size() > 0) {
			stringBuilder.append(boomPngUrl.get(0));
		}
		if(boomPngUrl.size() > 1) {
			for (int i = 1; i < boomPngUrl.size(); i++) {
				stringBuilder.append("," + boomPngUrl.get(i));
			}
		}
		return boomFrameTime+","+boomMusicId+","+boomPngSizeW+","+boomPngSizeH+","+boomPngCenterOffsetX+","+boomPngCenterOffsetY+","
				+boomPngUrl.size()+","+stringBuilder.toString();
	}
}
